package smashedapples.air.sqlite.commands
{
	import flash.events.EventDispatcher;
	
	import smashedapples.air.sqlite.SQLiteDB;
	import smashedapples.air.sqlite.SQLiteTable;
	
	public class SQLiteBaseCommand extends EventDispatcher    
	{
		public function SQLiteBaseCommand(db:SQLiteDB, 
										  tableName:String, 
										  parameters:Object = null, 
										  result:Function = null, 
										  fault:Function = null)
		{
			
			this.db = db;
			this.tableName = tableName;
			
			if( parameters != null )
				this.parameters = parameters;
			
			if( result != null )
				this.result = result;
			
			if( fault != null )
				this.fault = fault;
			
			
			this.table = db.getTableByName( this.tableName );	
			this.pkName = table.primaryKey.name;
		}
		
		public var db:SQLiteDB;
		
		public var fault:Function;
		
		public var parameters:Object = {};
		
		public var pkName:String;
		
		public var result:Function;
		
		public var table:SQLiteTable; 
		
		public var tableName:String;

	}
}